import 'dart:async';

import 'package:audioplayers/audioplayers.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:studymanage/course/course_intro.dart';
import 'package:studymanage/remark/toRemark.dart';
import 'package:studymanage/util/request.dart';

class Student extends StatefulWidget {
  final Map<String,dynamic> detail;

  Student(this.detail);

  @override
  State<StatefulWidget> createState() {
    return StudentState();
  }
}

class StudentState extends State<Student> {
  int _currentTab = 0;
  Future<List> _studentCourseList;

  List _remarkList =[];

  int _currentType = 2; // 功课点评类型： 2 所有； 1 已点评； 0 未点评


  AudioPlayer audioPlayer = AudioPlayer();

  @override
  void initState() {

    _studentCourseList = Request().post<Map>("/multiapi/c198p_courseStudent",
        data: {
          "pageNum": 1,
          "pageSize": 10,
          "studentId": widget.detail['id']
        }).then((response){
         return response.data['list'];
    });
    super.initState();

  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      body: SafeArea(
        child: Container(
          height: MediaQuery.of(context).size.height,
          child: Stack(
            children: <Widget>[
              SingleChildScrollView(
                child: Container(
                  margin: EdgeInsets.only(
                    top: ScreenUtil().setHeight(44),
                  ),
                  child: Column(
                    children: <Widget>[
                      Offstage(
                        offstage: _currentTab != 0,
                        child: Container(
                          width: MediaQuery.of(context).size.width,
                          padding: EdgeInsets.only(
                            top: ScreenUtil().setHeight(20),
                          ),
                          decoration: BoxDecoration(
                            border: Border(
                              top: BorderSide(
                                color: Color.fromRGBO(248, 248, 248, 1),
                                width: ScreenUtil().setHeight(7.5),
                              ),
                            ),
                          ),
                          child: Column(
                            crossAxisAlignment: CrossAxisAlignment.center,
                            children: <Widget>[
                              CircleAvatar(
                                backgroundImage: NetworkImage(widget.detail['studentAvatar']),
                                radius: ScreenUtil().setWidth(30),
                              ),
                              Container(
                                margin: EdgeInsets.only(
                                  top: ScreenUtil().setHeight(13),
                                ),
                                child: Text(widget.detail['studentNickname'],
                                  style: TextStyle(
                                    fontFamily: 'PingFangSC-Medium',
                                    fontSize: ScreenUtil().setSp(16),
                                    fontWeight: FontWeight.w600,
                                    color: Color.fromRGBO(51, 51, 51, 1),
                                    height: 1,
                                  ),
                                ),
                              ),
                              Container(
                                margin: EdgeInsets.only(
                                  top: ScreenUtil().setHeight(8.5),
                                ),
                                child: Row(
                                  mainAxisAlignment: MainAxisAlignment.center,
                                  crossAxisAlignment: CrossAxisAlignment.center,
                                  children: <Widget>[
                                    Text(widget.detail['gender'],
                                      style: TextStyle(
                                        fontFamily: 'PingFangSC-Light',
                                        fontSize: ScreenUtil().setSp(11),
                                        fontWeight: FontWeight.w300,
                                        color: Color.fromRGBO(133, 133, 133, 1),
                                        height: 1,
                                      ),
                                    ),
                                    Container(
                                      width: ScreenUtil().setWidth(1),
                                      height: ScreenUtil().setHeight(11.5),
                                      color: Color.fromRGBO(133, 133, 133, 1),
                                      margin: EdgeInsets.only(
                                        left: ScreenUtil().setWidth(8),
                                        right: ScreenUtil().setWidth(8),
                                      ),
                                    ),
                                    Text(widget.detail['studentAddress'],
                                      style: TextStyle(
                                        fontFamily: 'PingFangSC-Light',
                                        fontSize: ScreenUtil().setSp(11),
                                        fontWeight: FontWeight.w300,
                                        color: Color.fromRGBO(133, 133, 133, 1),
                                        height: 1,
                                      ),
                                    ),
                                  ],
                                ),
                              ),
                              Container(
                                margin: EdgeInsets.only(
                                  top: ScreenUtil().setHeight(19),
                                ),
                                padding: EdgeInsets.only(
                                  left: ScreenUtil().setWidth(15),
                                  right: ScreenUtil().setWidth(15),
                                ),
                                decoration: BoxDecoration(
                                  border: Border(
                                    bottom: BorderSide(
                                      color: Color.fromRGBO(248, 248, 248, 1),
                                      width: ScreenUtil().setHeight(7.5),
                                    ),
                                  ),
                                ),
                                child: Column(
                                  crossAxisAlignment: CrossAxisAlignment.start,
                                  children: <Widget>[
                                    Row(
                                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                      crossAxisAlignment: CrossAxisAlignment.center,
                                      children: <Widget>[
                                        Text('学员简介',
                                          style: TextStyle(
                                            fontFamily: 'PingFangSC-Medium',
                                            fontSize: ScreenUtil().setSp(14),
                                            fontWeight: FontWeight.w600,
                                            color: Color.fromRGBO(51, 51, 51, 1),
                                            height: 1,
                                          ),
                                        ),
                                        Container(
                                          width: ScreenUtil().setWidth(275),
                                          height: ScreenUtil().setHeight(0.5),
                                          color: Color.fromRGBO(238, 238, 238, 1),
                                        ),
                                      ],
                                    ),
                                    Container(
                                      margin: EdgeInsets.only(
                                        top: ScreenUtil().setHeight(20.5),
                                        bottom: ScreenUtil().setHeight(26),
                                      ),
                                      child: Text(
                                        widget.detail['studentIntro'],
                                        style: TextStyle(
                                          fontFamily: 'PingFangSC-Light',
                                          fontSize: ScreenUtil().setSp(13),
                                          fontWeight: FontWeight.w300,
                                          color: Color.fromRGBO(102, 102, 102, 1),
                                        ),
                                      ),
                                    ),
                                  ],
                                ),
                              ),
                              Container(
                                child: Column(
                                  crossAxisAlignment: CrossAxisAlignment.start,
                                  children: <Widget>[
                                    Container(
                                      width: MediaQuery.of(context).size.width,
                                      padding: EdgeInsets.only(
                                        left: ScreenUtil().setWidth(13),
                                        right: ScreenUtil().setWidth(13),
                                        top: ScreenUtil().setHeight(19.5),
                                      ),
                                      child: Text('所学课程',
                                        style: TextStyle(
                                          fontFamily: 'PingFangSC-Medium',
                                          fontSize: ScreenUtil().setSp(16),
                                          color: Color.fromRGBO(51, 51, 51, 1),
                                          fontWeight: FontWeight.w600,
                                        ),
                                      ),
                                    ),
                                    FutureBuilder<List>(
                                      future: _studentCourseList,
                                      builder: (context,snapshot){
                                        if (snapshot.hasData) {
                                          return Container(
                                            margin: EdgeInsets.only(top: 40),
                                            child: ListView.builder(
                                              shrinkWrap: true,
                                              physics: NeverScrollableScrollPhysics(),
                                              itemCount: snapshot.data.length,
                                              itemBuilder: (context, index) {
                                                return Column(
                                                  children: <Widget>[
                                                    GestureDetector(
                                                      child: Container(
                                                        width: MediaQuery.of(context).size.width,
                                                        height: ScreenUtil().setWidth(83.5),
                                                        padding: EdgeInsets.only(
                                                        ),
                                                        margin: EdgeInsets.only(
                                                          left: ScreenUtil().setWidth(13),
                                                          right: ScreenUtil().setWidth(13),
                                                          bottom: index == snapshot.data.length - 1 ? ScreenUtil().setHeight(20) : 0,
                                                        ),
                                                        decoration: BoxDecoration(),
                                                        child: Row(
                                                          crossAxisAlignment: CrossAxisAlignment.start,
                                                          children: <Widget>[
                                                            Container(
                                                              width: ScreenUtil().setWidth(83),
                                                              height: ScreenUtil().setWidth(83),
                                                              decoration: BoxDecoration(
                                                                image: DecorationImage(
                                                                  image: NetworkImage(snapshot.data[index]['insetCoverUrl'],),
                                                                  fit: BoxFit.fill,
                                                                ),
                                                                borderRadius: BorderRadius.all(Radius.circular(ScreenUtil().setHeight(4))),
                                                              ),
                                                            ),
                                                            Container(
                                                              width: MediaQuery.of(context).size.width - ScreenUtil().setWidth(125),
                                                              height: ScreenUtil().setHeight(83),
                                                              margin: EdgeInsets.only(
                                                                left: ScreenUtil().setWidth(14.5),
                                                              ),
                                                              child: Column(
                                                                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                                                crossAxisAlignment: CrossAxisAlignment.start,
                                                                children: <Widget>[
                                                                  Column(
                                                                    crossAxisAlignment: CrossAxisAlignment.start,
                                                                    children: <Widget>[
                                                                      Text(snapshot.data[index]['courseName'],
                                                                        maxLines: 1,
                                                                        overflow: TextOverflow.ellipsis,
                                                                        style: TextStyle(
                                                                          fontFamily: 'PingFangSC-Medium',
                                                                          fontSize: ScreenUtil().setSp(14),
                                                                          color: Color.fromRGBO(51, 51, 51, 1),
                                                                          fontWeight: FontWeight.w600,
                                                                          height: 1,
                                                                        ),
                                                                      ),
                                                                      Container(
                                                                        margin: EdgeInsets.only(
                                                                          top: ScreenUtil().setHeight(5),
                                                                        ),
                                                                        child: Text(
                                                                          snapshot.data[index]['courseIntro'],
                                                                          maxLines: 2,
                                                                          style: TextStyle(
                                                                            fontFamily: 'PingFangSC-Regular',
                                                                            fontSize: ScreenUtil().setSp(11),
                                                                            fontWeight: FontWeight.w400,
                                                                            color: Color.fromRGBO(133, 133, 133, 1),
                                                                            height: 1.2,
                                                                          ),
                                                                          textAlign: TextAlign.justify,
                                                                          overflow: TextOverflow.ellipsis,
                                                                        ),
                                                                      ),
                                                                    ],
                                                                  ),
                                                                  Container(
                                                                    margin: EdgeInsets.only(
                                                                      bottom: ScreenUtil().setHeight(0),
                                                                    ),
                                                                    child: Row(
                                                                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                                                      crossAxisAlignment: CrossAxisAlignment.center,
                                                                      children: <Widget>[
                                                                        Row(
                                                                          crossAxisAlignment: CrossAxisAlignment.center,
                                                                          children: <Widget>[
                                                                            Icon(Icons.access_time,
                                                                              color: Color.fromRGBO(173, 173, 173, 1),
                                                                              size: ScreenUtil().setSp(14),
                                                                            ),
                                                                            Container(
                                                                              margin: EdgeInsets.only(
                                                                                left: ScreenUtil().setWidth(5),
                                                                              ),
                                                                              child: Text(snapshot.data[index]['studyState'] != 1 ? snapshot.data[index]['courseProgress'] : '未学习',
                                                                                style: TextStyle(
                                                                                  fontFamily: 'PingFangSC-Regular',
                                                                                  fontSize: ScreenUtil().setSp(11),
                                                                                  fontWeight: FontWeight.w600,
                                                                                  color: Color.fromRGBO(51, 51, 51, 1),
                                                                                  height: 1,
                                                                                ),
                                                                              ),
                                                                            ),
                                                                          ],
                                                                        ),
                                                                      ],
                                                                    ),
                                                                  )
                                                                ],
                                                              ),
                                                            ),
                                                          ],
                                                        ),
                                                      ),
                                                      onTap: () {
                                                        Request().post<Map<String,dynamic>>("/multiapi/c188v_course",data: {"id":snapshot.data[index]['id']}).then((response) {
                                                          Navigator.push(context, MaterialPageRoute(builder: (context) => CourseIntro(response.data,snapshot.data[index]['id'],null,null)));
                                                        });
                                                      },
                                                    ),
                                                    Divider(height: 40,)
                                                  ],
                                                );
                                              },
                                            ),
                                          );
                                        }else{
                                          return Center(child: Text("暂无"),);
                                        }
                                      },
                                    )
                                  ],
                                ),
                              ),
                            ],
                          ),
                        ),
                      ),
                      Offstage(
                        offstage: _currentTab != 1,
                        child: Container(
                          width: MediaQuery.of(context).size.width,
                          child: Column(
                            children: <Widget>[
                              Container(
                                height: ScreenUtil().setHeight(45),
                                padding: EdgeInsets.only(
                                  left: ScreenUtil().setWidth(12.5),
                                  right: ScreenUtil().setWidth(12.5),
                                ),
                                color: Color.fromRGBO(248, 248, 248, 1),
                                child: Row(
                                  children: <Widget>[
                                    Container(
                                      width: ScreenUtil().setWidth(40),
                                      height: ScreenUtil().setHeight(23),
                                      color: _currentType == 2 ? Color.fromRGBO(214, 178, 128, 1) : Colors.transparent,
                                      margin: EdgeInsets.only(
                                        right: ScreenUtil().setWidth(12.5),
                                      ),
                                      child: FlatButton(
                                        padding: EdgeInsets.all(0),
                                        child: Text('全部',
                                          style: TextStyle(
                                            fontFamily: 'PingFangSC-Regular',
                                            fontSize: ScreenUtil().setSp(12),
                                            fontWeight: FontWeight.w300,
                                            color: _currentType == 2 ? Colors.white : Color.fromRGBO(51, 51, 51, 1),
                                            height: 1,
                                          ),
                                        ),
                                        onPressed: () {
                                          _remark("0");
                                          setState(() {
                                            _currentType = 2;
                                          });

                                        },
                                      ),
                                    ),
                                    Container(
                                      width: ScreenUtil().setWidth(50),
                                      height: ScreenUtil().setHeight(23),
                                      color: _currentType == 1 ? Color.fromRGBO(214, 178, 128, 1) : Colors.transparent,
                                      margin: EdgeInsets.only(
                                        right: ScreenUtil().setWidth(12.5),
                                      ),
                                      child: FlatButton(
                                        padding: EdgeInsets.all(0),
                                        child: Text('已点评',
                                          style: TextStyle(
                                            fontFamily: 'PingFangSC-Regular',
                                            fontSize: ScreenUtil().setSp(12),
                                            fontWeight: FontWeight.w300,
                                            color: _currentType == 1 ? Colors.white : Color.fromRGBO(51, 51, 51, 1),
                                            height: 1,
                                          ),
                                        ),
                                        onPressed: () {
                                          _remark("2");
                                          setState(() {
                                            _currentType = 1;
                                          });
                                        },
                                      ),
                                    ),
                                    Container(
                                      width: ScreenUtil().setWidth(50),
                                      height: ScreenUtil().setHeight(23),
                                      color: _currentType == 0 ? Color.fromRGBO(214, 178, 128, 1) : Colors.transparent,
                                      margin: EdgeInsets.only(
                                        right: ScreenUtil().setWidth(12.5),
                                      ),
                                      child: FlatButton(
                                        padding: EdgeInsets.all(0),
                                        child: Text('未点评',
                                          style: TextStyle(
                                            fontFamily: 'PingFangSC-Regular',
                                            fontSize: ScreenUtil().setSp(12),
                                            fontWeight: FontWeight.w300,
                                            color: _currentType == 0 ? Colors.white : Color.fromRGBO(51, 51, 51, 1),
                                            height: 1,
                                          ),
                                        ),
                                        onPressed: () {
                                          _remark("1");
                                          setState(() {
                                            _currentType = 0;
                                          });
                                        },
                                      ),
                                    )
                                  ],
                                ),
                              ),

                              Container(
                                padding: EdgeInsets.only(
                                  left: ScreenUtil().setWidth(12.5),
                                  right: ScreenUtil().setWidth(12.5),
                                ),
                                child: Container(
                                  child:  ListView.builder(
                                    shrinkWrap: true,
                                    physics: NeverScrollableScrollPhysics(),
                                    itemCount: _remarkList.length,
                                    itemBuilder: (context, index) {
                                      return Container(
                                        margin: EdgeInsets.only(top:10),
                                        color: Colors.white,
                                        child: Column(
                                          children: <Widget>[
                                            Container(
                                              padding: EdgeInsets.all(13),
                                              decoration: BoxDecoration(
                                                  color: Color(0xffF8F8F8),
                                                  borderRadius: BorderRadius.circular(4)
                                              ),
                                              child: Column(
                                                crossAxisAlignment: CrossAxisAlignment.start,
                                                children: <Widget>[
                                                  Row(
                                                    crossAxisAlignment: CrossAxisAlignment.start,
                                                    children: <Widget>[
                                                      Container(
                                                        height: 41,
                                                        width: 41,
                                                        child: CircleAvatar(
                                                          backgroundImage: NetworkImage(_remarkList[index]['studentAvatar']),
                                                          radius: ScreenUtil().setWidth(20.5),
                                                        ),
                                                      ),
                                                      Expanded(
                                                        child: Container(
                                                          margin: EdgeInsets.only(left: 10),
                                                          child: Column(
                                                            crossAxisAlignment: CrossAxisAlignment.start,
                                                            children: <Widget>[
                                                              Row(
                                                                children: <Widget>[
                                                                  Text(
                                                                    _remarkList[index]['studentNickname'],
                                                                    style: TextStyle(
                                                                      fontFamily: 'PingFangSC-Medium',
                                                                      fontSize: ScreenUtil().setSp(14),
                                                                      fontWeight: FontWeight.w600,
                                                                      color: Color.fromRGBO(51, 51, 51, 1),
                                                                      height: 1,
                                                                    ),
                                                                  ),
                                                                  Container(
                                                                    width: 50,
                                                                    padding: EdgeInsets.all(3),
                                                                    margin: EdgeInsets.only(
                                                                      left: 3,
                                                                    ),
                                                                    decoration: BoxDecoration(
                                                                      border: Border.all(
                                                                        color: Color.fromRGBO(133, 133, 133, 1),
                                                                        width: ScreenUtil().setHeight(0.5),
                                                                      ),
                                                                      borderRadius: BorderRadius.all(
                                                                        Radius.circular(ScreenUtil().setHeight(2)),
                                                                      ),
                                                                    ),
                                                                    child: Text(
                                                                      _remarkList[index]['className'],
                                                                      overflow: TextOverflow.ellipsis,
                                                                      style: TextStyle(
                                                                        fontFamily: 'PingFangSC-Light',
                                                                        fontSize: ScreenUtil().setSp(10),
                                                                        fontWeight: FontWeight.w300,
                                                                        color: Color.fromRGBO(133, 133, 133, 1),
                                                                      ),
                                                                    ),
                                                                  ),
                                                                  Offstage(
                                                                    offstage: !_remarkList[index]['boolComplete'],
                                                                    child: Container(
                                                                      padding: EdgeInsets.all(3),
                                                                      margin: EdgeInsets.only(
                                                                        left: 3,
                                                                      ),
                                                                      decoration: BoxDecoration(
                                                                        border: Border.all(
                                                                          color: Color.fromRGBO(133, 133, 133, 1),
                                                                          width: ScreenUtil().setHeight(0.5),
                                                                        ),
                                                                        borderRadius: BorderRadius.all(
                                                                          Radius.circular(ScreenUtil().setHeight(2)),
                                                                        ),
                                                                      ),
                                                                      child: Text(
                                                                        "已经结业",
                                                                        style: TextStyle(
                                                                          fontFamily: 'PingFangSC-Light',
                                                                          fontSize: ScreenUtil().setSp(10),
                                                                          fontWeight: FontWeight.w300,
                                                                          color: Color.fromRGBO(133, 133, 133, 1),
                                                                        ),
                                                                      ),
                                                                    ),
                                                                  ),
                                                                ],
                                                              ),
                                                              Container(
                                                                margin: EdgeInsets.only(top: 5),
                                                                child: Row(
                                                                  children: <Widget>[
                                                                    Container(
                                                                      child: Text(
                                                                        _remarkList[index]['shareDateCN'],
                                                                        style: TextStyle(
                                                                          fontFamily: 'PingFangSC-Light',
                                                                          fontSize: ScreenUtil().setSp(11),
                                                                          fontWeight: FontWeight.w300,
                                                                          color: Color.fromRGBO(133, 133, 133, 1),
                                                                          height: 1,
                                                                        ),
                                                                      ),
                                                                    ),
                                                                    Offstage(
                                                                      offstage: !_remarkList[index].containsKey("shareVoiceAudioDuration") || _remarkList[index]['shareRecordContentVoice']=='' ,
                                                                      child: GestureDetector(
                                                                        child: Container(
                                                                            margin: EdgeInsets.only(left: 8),
                                                                            child: Image.asset("assets/images/mine/ydp_bfanky.png")
                                                                        ),
                                                                        onTap: (){
                                                                          audioPlayer.play(_remarkList[index]['shareRecordContentVoice']);
                                                                        },
                                                                      ),
                                                                    )
                                                                  ],
                                                                ),
                                                              )
                                                            ],
                                                          ),
                                                        ),
                                                      ),
                                                      Offstage(
                                                        offstage: _remarkList[index]['boolCommentEnum'] == 1,
                                                        child: Container(
                                                          width: 42,
                                                          height: 23,
                                                          decoration: BoxDecoration(
                                                              color: Color.fromRGBO(214, 178, 128, 1),
                                                              borderRadius: BorderRadius.circular(2)
                                                          ),
                                                          child: FlatButton(
                                                            padding: EdgeInsets.all(0),
                                                            child: Text(
                                                              '点评',
                                                              style: TextStyle(
                                                                fontFamily: 'PingFangSC-Regular',
                                                                fontSize: ScreenUtil().setSp(12),
                                                                color: Colors.white,
                                                              ),
                                                            ),
                                                            onPressed: () {
                                                              Navigator.push(context, MaterialPageRoute(builder: (context) => ToRemark(_remarkList[index],(s)=>_update(s, index))));
                                                            },
                                                          ),
                                                        ),
                                                      ),
                                                    ],
                                                  ),
                                                  Container(
                                                    margin: EdgeInsets.only(left: 51,top: 10),
                                                    child: Text(_remarkList[index]['shareRecordContent']),
                                                  )

                                                ],
                                              ),
                                            ),
                                            Offstage(
                                              offstage: _remarkList[index]['boolCommentEnum'] != 1,
                                              child: Container(
                                                margin: EdgeInsets.only(top: 23),
                                                child: Column(
                                                  crossAxisAlignment: CrossAxisAlignment.end,
                                                  children: <Widget>[
                                                    Row(
                                                      mainAxisAlignment: MainAxisAlignment.end,
                                                      crossAxisAlignment: CrossAxisAlignment.center,
                                                      children: <Widget>[
                                                        Column(
                                                          crossAxisAlignment: CrossAxisAlignment.end,
                                                          children: <Widget>[
                                                            Row(
                                                              crossAxisAlignment: CrossAxisAlignment.center,
                                                              children: <Widget>[
                                                                Container(
                                                                  padding: EdgeInsets.only(
                                                                    left: ScreenUtil().setWidth(4.5),
                                                                    right: ScreenUtil().setWidth(4.5),
                                                                    top: ScreenUtil().setHeight(3.5),
                                                                    bottom: ScreenUtil().setHeight(3.5),
                                                                  ),
                                                                  margin: EdgeInsets.only(
                                                                    right: ScreenUtil().setWidth(9.5),
                                                                  ),
                                                                  decoration: BoxDecoration(
                                                                    border: Border.all(
                                                                      color: Color.fromRGBO(133, 133, 133, 1),
                                                                      width: ScreenUtil().setHeight(0.5),
                                                                    ),
                                                                    borderRadius: BorderRadius.all(
                                                                      Radius.circular(ScreenUtil().setHeight(2)),
                                                                    ),
                                                                  ),
                                                                  child: Text(
                                                                    '情感导师点评',
                                                                    style: TextStyle(
                                                                      fontFamily: 'PingFangSC-Light',
                                                                      fontSize: ScreenUtil().setSp(10),
                                                                      fontWeight: FontWeight.w300,
                                                                      color: Color.fromRGBO(133, 133, 133, 1),
                                                                    ),
                                                                  ),
                                                                ),
                                                                Text(
                                                                  _remarkList[index]['teacherNickname']==null ? "-" : _remarkList[index]['teacherNickname'],
                                                                  style: TextStyle(
                                                                    fontFamily: 'PingFangSC-Medium',
                                                                    fontSize: ScreenUtil().setSp(14),
                                                                    fontWeight: FontWeight.w600,
                                                                    color: Color.fromRGBO(51, 51, 51, 1),
                                                                    height: 1,
                                                                  ),
                                                                ),
                                                              ],
                                                            ),
                                                            Container(
                                                              margin: EdgeInsets.only(top: 5),
                                                              child: Row(
                                                                children: <Widget>[
                                                                  Container(
                                                                    margin: EdgeInsets.only(right: 8),
                                                                    child: Text(
                                                                      _remarkList[index]['commentDateCN'] != null ? _remarkList[index]['commentDateCN'] : '',
                                                                      style: TextStyle(
                                                                        fontFamily: 'PingFangSC-Light',
                                                                        fontSize: ScreenUtil().setSp(11),
                                                                        fontWeight: FontWeight.w300,
                                                                        color: Color.fromRGBO(133, 133, 133, 1),
                                                                        height: 1,
                                                                      ),
                                                                    ),
                                                                  ),
                                                                  Offstage(
                                                                    offstage: !_remarkList[index].containsKey("teacherContentVoice")||_remarkList[index]['teacherContentVoice']=='',
                                                                    child: GestureDetector(
                                                                      child: Image.asset("assets/images/mine/ydp_bfanky.png"),
                                                                      onTap: (){
                                                                        audioPlayer.play(_remarkList[index]['teacherContentVoice']);
                                                                      },
                                                                    ),
                                                                  )
                                                                ],
                                                              ),
                                                            )
                                                          ],
                                                        ),
                                                        Container(
                                                          height: 41,
                                                          width: 41,
                                                          margin: EdgeInsets.only(left: 10),
                                                          child: CircleAvatar(
                                                            backgroundImage: NetworkImage(_remarkList[index]['teacherAvatar'] != null ? _remarkList[index]['teacherAvatar'] : ''),
                                                            radius: ScreenUtil().setWidth(20.5),
                                                          ),
                                                        ),
                                                      ],
                                                    ),
                                                    Container(
                                                      margin: EdgeInsets.only(right: 51,top: 10,left: 51),
                                                      alignment: Alignment.topRight,
                                                      child: Column(
                                                        crossAxisAlignment: CrossAxisAlignment.start,
                                                        children: <Widget>[
                                                          Column(
                                                            crossAxisAlignment: CrossAxisAlignment.end,
                                                            children: <Widget>[
                                                              Text(_remarkList[index]['teacherContent']!=null  ? _remarkList[index]['teacherContent'] :"暂无评价"),
                                                              Container(
                                                                  height: 0,
                                                                  child: Text(_remarkList[index]['taskTitle'],style: TextStyle(fontSize: ScreenUtil().setSp(11),),)
                                                              ),

                                                            ],
                                                          ),
                                                          Container(
                                                            decoration: BoxDecoration(
                                                                border: Border.all(
                                                                  color: Color.fromRGBO(133, 133, 133, 1),
                                                                  width: ScreenUtil().setHeight(0.5),
                                                                ),
                                                                borderRadius: BorderRadius.circular(2)
                                                            ),
                                                            margin: EdgeInsets.only(top: 10),
                                                            padding: EdgeInsets.all(3),
                                                            child: Text(
                                                              _remarkList[index]['taskTitle'],
                                                              maxLines: 1,
                                                              overflow: TextOverflow.ellipsis,
                                                              style: TextStyle(
                                                                fontFamily: 'PingFangSC-Regular',
                                                                fontSize: ScreenUtil().setSp(11),
                                                                color: Color.fromRGBO(133, 133, 133, 1),
                                                              ),
                                                            ),
                                                          ),
                                                        ],
                                                      ),
                                                    ),

                                                  ],
                                                ),
                                              ),
                                            ),
                                          ],
                                        ),
                                      );
                                    },
                                  ),
                                ),
                              ),
                            ],
                          ),
                        ),
                      ),
                    ],
                  ),
                ),
              ),
              Positioned(
                top: 0,
                child: Container(
                  width: MediaQuery.of(context).size.width,
                  color: Colors.white,
                  child: Row(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: <Widget>[
                      Container(
                        width: ScreenUtil().setWidth(50),
                        height: ScreenUtil().setHeight(44),
                        child: IconButton(
                          icon: Icon(
                            Icons.navigate_before,
                            size: ScreenUtil().setSp(30),
                          ),
                          onPressed: () {
                            Navigator.pop(context);
                          },
                        ),
                      ),
                      GestureDetector(
                        child: Container(
                          width: (MediaQuery.of(context).size.width) / 2 -
                              ScreenUtil().setWidth(50),
                          child: Column(
                            mainAxisAlignment: MainAxisAlignment.start,
                            children: <Widget>[
                              Container(
                                height: ScreenUtil().setHeight(42.5),
                                padding: EdgeInsets.only(
                                  top: ScreenUtil().setHeight(16),
                                ),
                                child: Text(
                                  '学员信息',
                                  style: TextStyle(
                                    fontFamily: 'PingFangSC-Medium',
                                    fontSize: ScreenUtil().setSp(16),
                                    fontWeight: FontWeight.w600,
                                    color: _currentTab == 0
                                        ? Color.fromRGBO(210, 180, 142, 1)
                                        : Color.fromRGBO(51, 51, 51, 1),
                                    height: 1,
                                  ),
                                ),
                              ),
                              Offstage(
                                offstage: _currentTab != 0,
                                child: Container(
                                  width: ScreenUtil().setWidth(20),
                                  height: ScreenUtil().setHeight(1.5),
                                  color: Color.fromRGBO(210, 180, 142, 1),
                                ),
                              )
                            ],
                          ),
                        ),
                        onTap: () {
                          setState(() {
                            _currentTab = 0;
                          });
                        },
                      ),
                      GestureDetector(
                        child: Container(
                          width: (MediaQuery.of(context).size.width) / 2 -
                              ScreenUtil().setWidth(50),
                          child: Column(
                            mainAxisAlignment: MainAxisAlignment.start,
                            children: <Widget>[
                              Container(
                                height: ScreenUtil().setHeight(42.5),
                                padding: EdgeInsets.only(
                                  top: ScreenUtil().setHeight(16),
                                ),
                                child: Text(
                                  '功课点评',
                                  style: TextStyle(
                                    fontFamily: 'PingFangSC-Medium',
                                    fontSize: ScreenUtil().setSp(16),
                                    fontWeight: FontWeight.w600,
                                    color: _currentTab == 1
                                        ? Color.fromRGBO(210, 180, 142, 1)
                                        : Color.fromRGBO(51, 51, 51, 1),
                                    height: 1,
                                  ),
                                ),
                              ),
                              Offstage(
                                offstage: _currentTab != 1,
                                child: Container(
                                  width: ScreenUtil().setWidth(20),
                                  height: ScreenUtil().setHeight(1.5),
                                  color: Color.fromRGBO(210, 180, 142, 1),
                                ),
                              ),
                            ],
                          ),
                        ),
                        onTap: () {
                          _remark("0");
                        },
                      ),
                    ],
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
  _remark(String state){
     Request().post("/multiapi/c204p_studyRecord",
          data: {
            "pageNum": 1,
            "pageSize": 10,
            "studentId":widget.detail['id'],
            "queryState": state//<comment>0=全部 1=未点评 , 2=已点评  </comment>
          }).then((responde){
             responde.data['list'].forEach((element) {
               element['isPlayAudio'] = false;
               element['initSchedule'] = 0;
               element['currentSchedule'] = 0.0;
               element['teacherIsPlayAudio'] = false;
               element['teacherInitSchedule'] = 0;
               element['teacherCurrentSchedule'] = 0.0;
             });
            setState(() {
             _remarkList= responde.data['list'];
             _currentTab = 1;
           });
    });
  }
  _update(s,index) {
    if(_currentTab ==0){
      _remark("1");
    }
    if(_currentTab == 2){
      _remark("0");
    }
    if(_currentTab == 1){
      _remark("2");
    }
  }
}
